package com.alibaba.cloud.client9092.service.impl;

import com.alibaba.cloud.client9092.dao.IndexDao;
import com.alibaba.cloud.client9092.service.ClientFeignService;
import com.alibaba.cloud.client9092.service.IndexService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * created by wuquan at 05/12/2021
 * ^_^ ^_^
 */

@Service
public class IndexServiceImpl implements IndexService {

    @Autowired
    private IndexDao indexDao;

    @Autowired
    private ClientFeignService clientFeignService;

    @GlobalTransactional(rollbackFor = Exception.class)
    @Override
    public int insert(String name) {
        indexDao.insertUser(name);
        clientFeignService.save(name);

        return 1;
    }
}
